package jflowmap.views.quadrant;

import java.awt.Color;
import java.awt.Paint;
import java.awt.Stroke;
import java.awt.geom.Point2D;

import jflowmap.util.piccolo.PPaths;
import edu.umd.cs.piccolo.PNode;
import edu.umd.cs.piccolo.nodes.PPath;
import edu.umd.cs.piccolox.util.PFixedWidthStroke;

public class AverageCross extends PNode {
	private static final long serialVersionUID = 1L;
	
	private static final Stroke CROSS_STROKE = new PFixedWidthStroke(2);
	private static final Paint CROSS_PAINT = new Color(50, 50, 50, 200);
	
	private final VisualSpiral visualSpiral;
	private final PPath xCoord;
	private final PPath yCoord;
		
	public AverageCross(VisualSpiral visualSpiral) {
		this.visualSpiral = visualSpiral;

		final double minX = visualSpiral.getXMinProjection();
		final double spanX = visualSpiral.getXSpanProjection();
		final double minY = visualSpiral.getYMinProjection();
		final double spanY = visualSpiral.getYSpanProjection();
		
		final double maxX = minX + spanX;
		final double maxY = minY + spanY;
		final double avgX = visualSpiral.xToProjection(visualSpiral.getXAvgValue());
		final double avgY = visualSpiral.yToProjection(visualSpiral.getYAvgValue());
		
		xCoord = new PPath();
		xCoord.append(PPaths.createArrowShape(new Point2D.Double(minX-500, avgY),
				new Point2D.Double(maxX+500, avgY), 2, 45), false);
		xCoord.setStroke(CROSS_STROKE);
		xCoord.setStrokePaint(CROSS_PAINT);
		addChild(xCoord);
		
		yCoord = new PPath();
		yCoord.append(PPaths.createArrowShape(new Point2D.Double(avgX, minY-500),
				new Point2D.Double(avgX, maxY+500), 2, 45), false);
		yCoord.setStroke(CROSS_STROKE);
		yCoord.setStrokePaint(CROSS_PAINT);
		addChild(yCoord);
	}

}
